package scct.zhouyuzhe.utils;
import java.sql.*;
public class DBUtils {
    private static String Driver="com.mysql.cj.jdbc.Driver";
    private static String dbUrl ="jdbc:mysql://localhost:3306/storedb?characterEncoding=UTF-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=GMT%2B8";
    private static String username="root";
    private static String password="123456";

    public static Connection getConnection(){
        Connection conn=null;
        try {
            Class.forName(Driver);
            conn = DriverManager.getConnection(dbUrl, username, password);
        }catch (ClassNotFoundException | SQLException e){
            throw new RuntimeException(e);
        }
        return conn;
    }
    public static void close(Connection conn){
        if (conn !=null){
            try {
                conn.close();
            }catch(SQLException e){
                throw new RuntimeException(e);

            }
        }
    }

    public static void closeConnection(Connection conn) {
    }
}